package collection02;

import collection.Point;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
        Collection<Point> c = new ArrayList();
        c.add(new Point(1, 2));
        c.add(new Point(3, 4));
        c.add(new Point(5, 6));
        c.add(new Point(7, 8));
        c.add(new Point(9, 0));
        System.out.println(c);

        Iterator<Point> it = c.iterator();
        while (it.hasNext()) {
            Point p = it.next();
            System.out.println(p);
        }
        for (Point p : c) {
            System.out.println(p);
        }

        Collection<String> c1 = new ArrayList<>();
        c1.add("one");
        c1.add("two");
        c1.add("three");
        c1.add("four");
        c1.add("five");
        Iterator<String> it1 = c1.iterator();
        while (it1.hasNext()) {
            String str = it1.next();
            System.out.println(str);
        }

        for (String str:c1){
            System.out.println(str);
        }

    }


}
